const person = {
  name: 'face',
};

/* 
   Reflect可以配合Proxy对对象的某些操作做拦截和修改
*/

// Reflect.get
const reflectPerson = Reflect.get(person, 'name');
console.log(reflectPerson);

// Reflect.set
Reflect.set(person, 'name', 'book');
console.log(person);

// Reflect.has
const isName1 = Reflect.has(person, 'name');
console.log('isName1', isName1);

// Reflect.deleteProperty
Reflect.deleteProperty(person, 'name');
console.log(person);

const isName2 = Reflect.has(person, 'name');
console.log('isName2', isName2);

// Reflect.defineProperty
const isSetSuccess = Reflect.defineProperty(person, 'age', {
  value: '20',
  enumerable: true,
});
console.log('person', person);

const proxyPerson = new Proxy(person, {
  get(target, key, receiver) {
    console.log(`get ${key}`);
    return Reflect.get(target, key, receiver);
  },
});
console.log(proxyPerson.age);
